home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / c_news / 08 / cnews008.nws
Text File  |  1988-06-13  |  39KB  |  995 lines

  1. Volume 1, Number  8                                   11 Jun 1988  
  2. +---------------------------------------------------------------+  
  3. |                                                               |  
  4. |                       -  C   News  -                          |  
  5. |                                                               |  
  6. |                        International                          |  
  7. |                C Programming & Compiler Review                |  
  8. |                         Newsletter                            |  
  9. |                                                               |  
  10. +---------------------------------------------------------------+  
  11. US Office:  
  12. Editor                                                Barry Lynch  
  13. Technical Editor                                Marshall Presnell  
  14.   
  15. Australian Office:       
  16. Editor                                               David Nugent  
  17. Asst Editor                                          Kevin Bergin 
  18.   
  19. C News  is  published  monthly by  the  C BBS as its official  
  20. newsletter.  You are encouraged to submit articles for publication  
  21. in C News.  Articles should be related to C programming and can be  
  22. Tutorials, reviews or articles of interest to the C programming  
  23. community.  All Operating systems are fairly represented and this  
  24. newsletter shows no favoritism to any one in particular.  Instruct-  
  25. ions on how to submit articles for publication is included on the  
  26. last page.   
  27.             
  28. C News is the property of the C BBS and is Copyright 1988 by the  
  29. the C BBS.  All rights are reserved and distribution is limited to  
  30. electronic distribution and personal printed copies.  C News cannot  
  31. be resold at any profit, by any organization.  All material enclosed  
  32. within the newsletter is the opinions of the writers and not the  
  33. C BBS or it's Sysop. 
  34. C News 1-08                                           11 Jun 1988  
  35.   
  36. =================================================================  
  37.                        TABLE OF CONTENTS  
  38. =================================================================  
  39.        
  40.   
  41. 1. EDITORIAL   
  42.         The Heap: messages from the editor....................  1  
  43.        
  44. 2. BUG Report: MSC C 5.01 & QC 1.01
  45.         PrintF Function  .....................................  2  
  46.  
  47. 3. SOFTWARE REVIEW
  48.    Public Domain:  ...........................................  4
  49.    EZ-Window V1.1 by Barry Lynch
  50.  
  51. 4. Programming for The Hercules Graphics
  52.        Card by David Cheslow   ...............................  5
  53.  
  54. 5. LATEST VERSIONS OF COMMERCIAL/Public Domain   ............. 16 
  55.    Software  by Barry Lynch
  56.  
  57. 6. NOTES  
  58.    Article Submission Standards  ............................. 17  
  59.    Address's   ............................................... 18  
  60.    USER Response Form  ....................................... 19 
  61.      
  62. 7. INDEX   ................................................... 20  
  63.  
  64. 8. Distribution Points   ..................................... 22 
  65.  
  66. C News 1-08                 Page 1                   11 Jun 1988 
  67.  
  68. ================================================================ 
  69. The Heap:  Messages from the editor   
  70. ================================================================ 
  71.  
  72.      C News is alive and well again.  This issue marks the debut. 
  73. of a new section: Current Versions of Commercial and Public Domain
  74. Software.  You will notice that there are quite a few files and
  75. compilers missing.  In time I will get around to them all, but as I 
  76. do not use all of the compilers on the market.  Finding out what the
  77. lastest version is, is a challenge.  Therefore, if you are using
  78. a compiler that does not have a version number listed.  Please place
  79. a netmail message in the C Echo or on the C BBS.  Thanks for your  
  80. support in this matter.  
  81.  
  82.   Along the same lines, I would like to ask all C Shareware/Public
  83. Domain authors to send copies of their products to the C BBS.  So
  84. that may be reviewed and highlighted in future issues of C News.
  85. C News is for all users, readers, and developers.
  86.  
  87.    This issue also features the first in a series of articles on 
  88. programming the Hercules Graphics Adapter.  This article also, 
  89. focuses around a compiler other than the big three <MSC, Borland
  90. and Lattice>. MIX C.  This is a trend that I would like to see
  91. more of.
  92.  
  93.      Finally, as I put the finishing touches on Issue 8, I cannot 
  94. help but feel somewhat proud of what we have created.  The users
  95. make C News what it is, and I hope it continues.
  96.  
  97. Barry Lynch
  98.  
  99. Burke, VA
  100. C News 1-08                 Page 2                   11 Jun 1988 
  101.  
  102. ================================================================ 
  103. BUG Report: Microsoft Strikes Again!  
  104. ================================================================ 
  105.  
  106. *** Editors Note:  The following is the text file included
  107.     with the Official Microsoft Patch.  Copyright Microsoft
  108.     1988.
  109.  
  110.   
  111.      This file contains replacement object files to correct a
  112. problem with formatted output in the Microsoft C 5.10 runtime.
  113. Specificly, printf would not zero fill floating point numbers when
  114. the specified precision is zero. The cprintf() function also has
  115. this problem.  This is demonstrated by the following example.
  116.  
  117.  
  118.               #include <stdio.h>
  119.  
  120.               main(void)
  121.               {
  122.  
  123.                  printf("%04.0f\n", 12.34);
  124.  
  125.               }
  126.  
  127. The current runtime library will output '  12'.  With this update,
  128. the library will output '0012'.
  129.  
  130.    The following is a list of the files in this archive.
  131.  
  132.  
  133.      README.DOC          This file.
  134.      UPDATE.BAT          DOS batch file to update all libraries.
  135.      UPDATE.CMD          OS/2 batch file to update all libraries.
  136.  
  137.      OUTPUT.S       OUTPUT.OBJ for small model libraries.
  138.      OUTPUT.M       OUTPUT.OBJ for medium model libraries.
  139.      OUTPUT.C       OUTPUT.OBJ for compact model libraries.
  140.      OUTPUT.L       OUTPUT.OBJ for large model libraries.
  141.      OUTPUT.CRT          OUTPUT.OBJ for CDLLOBJS.LIB
  142.      OUTPUT.DLL          OUTPUT.OBJ for LLIBCDLL.LIB
  143.      OUTPUT.MT      OUTPUT.OBJ for LLIBCMT.LIB
  144.  
  145.      CPRINTF.S      CPRINTF.OBJ for small model libraries.
  146.      CPRINTF.M      CPRINTF.OBJ for medium model libraries.
  147.      CPRINTF.C      CPRINTF.OBJ for compact model libraries.
  148.      CPRINTF.L      CPRINTF.OBJ for large model libraries.
  149.      CPRINTF.CRT         CPRINTF.OBJ for CDLLOBJS.LIB
  150.      CPRINTF.DLL         CPRINTF.OBJ for LLIBCDLL.LIB
  151.      CPRINTF.MT          CPRINTF.OBJ for LLIBCMT.LIB
  152.  
  153.  
  154. C News 1-08                 Page 3                   11 Jun 1988 
  155.  
  156. ================================================================ 
  157. Bug Report: Microsoft Strikes Again   
  158. ================================================================ 
  159.  
  160.    To update your libraries, you should place all these files in
  161. the same directory as the libraries and type UPDATE.  The process
  162. may take a some time depending on the number of libraries you
  163. created during installation.
  164.  
  165.  
  166.    The update procedure will create a backup of each library with
  167. the file extension .BAK.  After you assure yourself that the update
  168. completed without error (for example insufficient disk space), you
  169. can delete the backups.  The original combined libraries can always
  170. be regenerated using the SETUP program and the distribution disks.
  171. C News 1-08                 Page 4                   11 Jun 1988 
  172.  
  173. ================================================================ 
  174. PUBLIC DOMAIN SOFTWARE REVIEWS:
  175. ================================================================ 
  176.    
  177. Filename: EZWIND.ARC
  178.  
  179.      This is another of the "add-on graphics libraries" that are
  180. available for the more popular MS-DOS C compilers on the market
  181. today.  Others include: WindowBoss, and C Spot Run.  All are 
  182. excellent and I was curious as to why someone thought they had to
  183. create another.
  184.  
  185.      This version of EZ Window (1.1) is for Microsoft C 5.0 and
  186. QuickC.  At this time, it is not known if versions are available
  187. for TurboC, MIX C, or Datalight.  EZ Window's main selling point
  188. is the ease of use.  I have played with all of the major and
  189. minor windows libraries that are in the Public Domain.  This is
  190. not the most powerful by any means.  But the creation and manip-
  191. ulation of Text Windows, with sound effects and shadowing is quite
  192. simple.  The author <Don Fordham> has done an excellent job on the
  193. documentation, that helps in the ease of use.  The sample programs
  194. that are included are simple, and stress the point.  All in all, 
  195. this is a simple, non-pretentious package that is highly recommended
  196. for all C programmers.
  197.  
  198. Source Included: No, except for sample programs.
  199. Compiler: Microsoft only. Supports Small and Large models.
  200.  
  201.  
  202. C News 1-08                Page 5                    11 Jun 1988 
  203.  
  204. ================================================================
  205. Programming for the Hercules Graphics Card by David Cheslow.
  206. ================================================================
  207.      
  208. This is the first in a series of articles about the Hercules
  209. Graphics Adapter, specifically, the graphics modes of that adapter.
  210. The Hercules is not supported by many standard compiler libraries
  211. and, when it is supported, it is usually underutilized.
  212.  
  213. Since this is the first article about the subject, some general
  214. information on the Hercules is appropriate.  The Hercules (when in 
  215. text mode) is 100% compatible with the IBM Monochrome Graphics 
  216. Adapter.  Because there are so many good public domain libraries
  217. which support the Monochrome, this column will not address issues 
  218. pertaining to that mode.  When the Hercules is in graphics mode, 
  219. however, it can produce dazzling 720 x 348 pixel monochrome 
  220. graphics.  Because IBM never endorsed a monochrome graphics
  221. standard the BIOS which is in IBM and clone machines offers no
  222. support for the Hercules defacto standard.  In order to make use
  223. of the terrific resolution of the Hercules graphics modes, you must
  224. either buy software from Hercules or write the routines yourself. 
  225. The first option is not altogether satisfactory because in order to
  226. distribute the Hercules software you must make an agreement with 
  227. Hercules.  For commercial software developers this is not a serious
  228. problem, but for the hacker or public domain software developer this 
  229. is just too much trouble.  Because of this, very few public domain 
  230. programs support the Hercules graphics mode.
  231.  
  232. This article will, over the next several months, provide a complete
  233. graphics environment for the Hercules graphics mode.  By 'complete' I 
  234. mean a windowing environment with pulldown menus, multiple resizable 
  235. moveable scrollable popup windows, animation, multiple fonts, and a 
  236. bunch of graphics primitives for freestyle drawing.  In as much as I 
  237. haven't written all of the routines yet, I may have to revisit older 
  238. routines from time to time to make them compatible with other not
  239. yet written routines.  Whenever possible, the code that is provided
  240. will be completely portable.  In addition, assembler routines will be 
  241. provided to increase the speed of some routines.  I will attempt to 
  242. keep the assembler routines to a minimum (after all, this is a 
  243. newsletter for 'C' programmers not assembler programmers). The routines
  244. will be provided only when they are needed to provide added portability
  245. or when they improve performance substantially.
  246.  
  247. One of the joys of graphics programming is using the mouse as an 
  248. input device.  I will occasionally digress from the subject of 
  249. Hercules graphics and wander off into the world of mouse functions.  
  250. These functions will be presented so as to be compatible with all the 
  251. IBM graphics modes.
  252.  
  253. One caveat before I begin.  I use the MIX Power C medium memory model 
  254. compiler, it is the only compiler I own.  I chose the Power C 
  255. compiler because it is fully functional and dirt cheap. 
  256. C News 1-08                Page 6                    11 Jun 1988 
  257. ================================================================
  258. Programming for the Hercules Graphics Card by David Cheslow.    
  259. ================================================================
  260.  
  261.      Since I have only the one compiler, I am not qualified to
  262. review its capabilities compared to other compilers but I am
  263. satisfied with it. The Power C compiler comes with its own
  264. assembler which is not entirely compatible with MASM.  When I
  265. present assembler code with the Hercules routines, I will do my
  266. best to provide MASM compatible code ... I guarantee nothing. 
  267. I hope that readers of this article will provide me with feedback
  268. about using these routines with other compilers and assemblers.
  269.  
  270. That's about enough background for this month ... on with the
  271. show!   This time I will present routines for:
  272.  
  273.          1) Detecting a Hercules graphics adapter;
  274.          2) Switching the Hercules into/out of graphics mode;
  275.          3) Switching between graphics 'pages';
  276.          4) Blanking/restoring the Hercules adapter;
  277.          5) Detecting a mouse driver; and
  278.          6) Turning the mouse cursor on/off
  279.  
  280. This group of functions doesn't really let you do anything - I
  281. apologize for this.  These functions, while not visibly spect-
  282. acular, are the foundation upon which we are going to build the
  283. really fun stuff.  It is important that these functions are fully
  284. understood.  Please spend some time reading and examining them until
  285. you are comfortable with the concepts used.
  286.  
  287. If it's any consolation, my next article will cover 1) multiple
  288. raster fonts, 2) horizontal and vertical lines, 3) filled boxes and
  289. several more mouse functions.  Stay tuned!
  290.  
  291. 1) Detecting a Hercules graphics adapter
  292.  
  293. Detection of a Hercules adapter is accomplished in two steps.  First,
  294. we must ask the ROM BIOS what type of adapter IT thinks is attached.
  295. If the BIOS indicates that a monochrome adapter is NOT present then 
  296. we know that the adapter can not possibly be Hercules compatible 
  297. (remember that the Hercules is 100% compatible with the IBM Monchrome 
  298. Adapter).  If, however, the BIOS indicates that a monochrome adapter 
  299. IS installed, then we must determine the amount of RAM memory the 
  300. adapter has.  The Monchrome has only 4000 bytes of memory (80 x 25 
  301. characters + 80 x 25 attributes); the Hercules has 65536 bytes (2
  302. graphics 'pages' with 32768 bytes per 'page').  Actually, only 31320 
  303. bytes are used on each 'page' (the others are left blank), but more 
  304. about that later.
  305.  
  306.  
  307.  
  308.  
  309.  
  310. C News 1-08                Page 7                    11 Jun 1988 
  311. ================================================================
  312. Programming for the Hercules Graphics Card by David Cheslow.
  313. ================================================================
  314.  
  315.  
  316. Determining what graphics adapter is installed is actually pretty 
  317. easy in this particular case.  The Monochrome can only exist in
  318. one mode (#7).  No other graphics adapter can exist in this mode.
  319. Since the Hercules is 100% compatible with the Monochrome, all we
  320. have to do is determine the current video mode.  If it is 7 then a
  321. Monochrome or Hercules is installed and we can continue with our
  322. checks.
  323.  
  324. This is the first of many functions I will present that require an 
  325. 'int86' function.  The prototype for the 'int86' function is - 
  326. void int86(int i, union REGS r1, union REGS r2). Where i is the DOS 
  327. interrupt number to be performed, r1 is a union containing the
  328. various NON-SEGMENT registers to be used when calling the interrupt,
  329. and r2 is an identical union in which the register values will be
  330. saved after the interrupt is completed.  This is a rather involved
  331. function to implement in assembler and since my compiler has an
  332. 'int86' function I have never tried to write one.  If your compiler
  333. doesn't have one please leave me a note on the Virginia (USA) C BBS
  334. and I will include one in a later article.  Has anyone out there
  335. already written one?
  336.  
  337. Here's the function:
  338.  
  339. int h_isherc(void)
  340. {
  341.    external char far *h_p;
  342.    union REGS regs;
  343.    char save_byte;
  344.    regs.h.ah=15;
  345.    int86(16,®s,®s);
  346.    if(regs.h.al!=7) return(-1);
  347.    h_p=H_MEMLOC;
  348.    save_byte=*(h_p+65535);
  349.    *(h_p+65535)=170;
  350.    if(*(h_p+65535)!=170) return(1);
  351.    *(h_p+65535)=85;
  352.    if(*(h_p+65535)!=85) return(1);
  353.    *(h_p+65535)=save byte;
  354.    return(0);
  355. }
  356.  
  357. LOCAL VARIABLES:
  358.  
  359. 'regs' is a union used in the 'int86' function.
  360.  
  361. 'save_byte' is used to store the contents of the last byte of
  362. Hercules memory.
  363.  
  364. C News 1-08                Page 8                    11 Jun 1988 
  365. ================================================================
  366. Programming for the Hercules Graphics Card by David Cheslow.
  367. ================================================================
  368.  
  369. PROCEDURE:
  370.  
  371. Ascii 15 is loaded into the ah register and BIOS interupt #16 is 
  372. called to return the current video mode (which is returned in the
  373. al register).
  374.  
  375. If the al register contains any value other than 7, then -1 is 
  376. returned by the function to indicate that a color adapter of some 
  377. sort is attached.
  378.  
  379. 'h_p' is initialized to point to Hercules memory.  Be sure to call
  380. this function before any other Hercules functions or you will wipe
  381. out the operating system and have to reboot the computer.
  382.  
  383. If the al register contains 7, however, the last byte of Hercules
  384. memory is saved in 'save_byte' and an attempt is made to change the
  385. that byte to ascii 170 (binary 10101010).  The byte is read again to 
  386. determine whether or not the change was successful.  The possibility 
  387. exists that the last byte of Hercules memory already contained ascii 
  388. 170, so the byte is changed to ascii 85 (binary 01010101, which is 
  389. mutually exclusive of ascii 170) and the byte is checked again to see 
  390. whether or not the change was successful.
  391.  
  392. If either of the changes was unsuccessful, then the function returns
  393. 1 to indicate that the adapter is Monochrome (or doesn't have enough 
  394. memory to be Hercules compatible).
  395.  
  396. Finally, the byte of Hercules memory is restored to its original
  397. value and the function returns 0 to indicate that a Hercules 
  398. compatible graphics adapter is installed.
  399.  
  400. 2) Switch the Hercules into/out of graphics mode
  401.  
  402. Some compilers offer a function to accomplish this, the name of the 
  403. function might be something like 'setvmode' or 'mode'. If your 
  404. compiler has this function, check to see if your compiler supports 
  405. the mouse.  If your compiler supports both the Hercules mode and the 
  406. mouse, then you're in luck!  These lucky people probably won't need
  407. this function.  If the compiler causes a click sound when changing
  408. to Hercules graphics mode, read on, we will cure that problem in this
  409. routine.
  410.  
  411. If your compiler has Hercules OR mouse support, but not the other,
  412. then you will need to use the function presented here.  We must per- 
  413. form some special programming to make the Hercules and the mouse work
  414. together. If your compiler does not support both, then chances are
  415. pretty good that this special programming was not implemented. 
  416. Improper implementation of this function may cause damage to your
  417.   
  418. C News 1-08                Page 9                    11 Jun 1988 
  419. ================================================================
  420. Programming for the Hercules Graphics Card by David Cheslow.
  421. ================================================================
  422.  
  423. graphics adapter or monitor - YOU accept full responsibility for
  424. what happens if you use it!  The author, C BBS and affiliated dis-
  425. tributors, and C NEWS absolve themselves of ANY responsibility with
  426. regard to this function!  As written, it has been fully tested and
  427. works better than any other similar function I have seen ... but,
  428. USE IT AT YOUR OWN RISK!
  429.  
  430. To use this function you will need an 'outp' function.  The prototype 
  431. for an 'outp' function is - void outp(unsigned p, int c).  The result 
  432. is that (char)int c is sent out port p.  In assembler the function 
  433. goes something like this:
  434.  
  435.     PUSH  BP
  436.     MOV   BP,SP
  437.     MOV   DX,[BP+6]
  438.     MOV   AX,[BP+8]
  439.     OUT   DX,AL
  440.     POP   BP
  441.  
  442. Where [BP+6] and [BP+8] are the parameters unsigned p and int c 
  443. respectively.
  444.  
  445. Here's the function:
  446.  
  447. int h_init(mode)
  448. int mode;
  449. {
  450.    extern int h_vpage,h_apage,h_xpos,h_ypos;
  451.    extern int h_pmode,h_vmode,h_color,h_start;
  452.    extern int h_xmax,h_xmin,h_ymax,h_ymin;
  453.    extern char far *h_p;
  454.    char text[]={97,80,82,15,25,6,25,25,2,13,11,12,0,0,0,0};
  455.    char graph[]={53,45,46,7,91,2,87,87,2,3,0,0,0,0,0,0};
  456.    char *ptr;
  457.    unsigned i;
  458.    union REGS reg;
  459.    outp(MODEPORT,((h_vmode==99)?2:0));
  460.    ptr=((mode==99)?graph:text);
  461.    regs.h.ah=0;
  462.    regs.h.al=((mode==99)?6:7);
  463.    int86(0x10,®,®);
  464.    outp(MODEPORT,((mode==99)?2:0);
  465.    for(i=0;i<16;i++)
  466.    {
  467.       outp(ADDRPORT,i);
  468.       outp(DATAPORT,*(ptr+i));
  469.    }
  470.  
  471.  
  472. C News 1-08                Page 10                   11 Jun 1988 
  473. ================================================================
  474. Programming for the Hercules Graphics Card by David Cheslow.
  475. ================================================================
  476.  
  477.    h_vpage=h_apage=h_xmin=h_ymin=h_ypos=h_xpos=h_pmode=h_start=0;
  478.    h_vmode=((mode==99)?99:7);
  479.    h_xmax=719;
  480.    h_ymax=347;
  481.    h_color=1;
  482.    if(mode==99)
  483.    {
  484.       for(i=0;i<=65535;i++) *(h_p+i)=0;
  485.    }
  486.    outp(MODEPORT,((mode==99)?10:8));
  487.    return(h_vmode);
  488. }
  489.  
  490. PARAMETERS:
  491.  
  492. 'mode' is the only parameter passed to the h_init function, if
  493. 'mode'==99 then graphics mode will be initialized, any other value 
  494. will cause text mode to be initialized.
  495.  
  496. LOCAL VARIABLES:
  497.  
  498. 'text[]' and 'graph[]' are arrays of character variables which will 
  499. be sent out of the DATAPORT to initialize the proper mode.
  500.  
  501. 'ptr' is a pointer into the 'text[]' or 'graph[]' arrays.
  502.  
  503. 'i' is a counter used for the two 'for' loops (i.e. loading the 
  504. DATAPORT registers and clearing Hercules RAM).
  505.  
  506. 'regs' is a union used by the 'int86' function.
  507.  
  508. PROCEDURE:
  509.  
  510. Unfortunately, the MODEPORT is an output only port, therefore we have
  511. to keep track of the current mode information and output the proper
  512. byte based on that data.  For this reason, your programs must never
  513. return to DOS without first restoring the Hercules to text mode. 
  514. Other programs have no way to determine the current video mode.
  515.  
  516. The 4th bit of MODEPORT controls whether or not the adapter is
  517. on or off, when the bit is 1 the adapter is on, otherwise the adapter 
  518. is off.  Turning the adapter off eliminates the flicker associated 
  519. with changing video modes and reduces the stress on the adapter and 
  520. monitor during the video mode change.  The 2nd bit controls (together
  521. with the DATAPORT registers) whether graphics or text mode is sel-
  522. ected. To turn the adapter off we send 2 out of MODEPORT if we are in
  523. graphics mode, 0 if we are in text mode.
  524.  
  525.  
  526. C News 1-08                Page 11                   11 Jun 1988 
  527. ================================================================
  528. Programming for the Hercules Graphics Card by David Cheslow.
  529. ================================================================
  530.  
  531. 'ptr' is set to point to the array 'graph[]' if 'mode'==99, other-
  532. wise it is set to point to 'text[]'.
  533.  
  534. The ah register is set equal to 0 and the al register is set to 6.  
  535. These are the registers needed to request a change to CGA high 
  536. resolution graphics mode using DOS interrupt 10.
  537.  
  538. If we are selecting text mode, 7 is placed in al to select Monochome
  539. mode.
  540.  
  541. DOS interrupt 10 Hex is issued with the values previously set in the
  542. ah and al registers.  This tricks the mouse driver (if present) into
  543. thinking that a graphics mode is selected.   CAUTION - be sure that 6
  544. is in the al register, other values (i.e. the ones used to select EGA
  545. modes) may cause damage to your monitor!  If you screw this up, you
  546. will hear a loud zap sound (like sticking a fork in a toaster while
  547. it's on) when you run this function ... if it zaps, turn your monitor
  548. off FAST and you might be able to save it!  You should not hear any
  549. even slightly alarming sound when this function runs.  Just be sure
  550. that 6 is in register al and you will have no trouble.  If you are
  551. not at all brave, and you don't want to use the mouse then you can
  552. simply delete the line with the 'int86' function call.
  553.  
  554. The 2nd bit of mode port is set to 1 to request graphics mode or 0 to 
  555. request text mode. This is only part of the process, however, the 
  556. DATAPORT values must also be changed to the appropriate values.
  557.  
  558. Send the 16 array values out of the DATAPORT after addressing each of 
  559. the 16 ADDRPORT registers.  It is always necessary to reprogram all 
  560. 16 of these registers for each mode change, even though both modes 
  561. have several values that are the same.
  562.  
  563. Reset the external variables to their default values.
  564.  
  565. Set all 65535 bytes of Hercules RAM to ascii 0 if we are selecting
  566. graphics mode.  This is not necessary if we are selecting text mode
  567. because the BIOS will clear that memory for us. ** See ASM SPEEDUP **
  568.  
  569. Turn the adapter back on by setting bit 4 to 1.
  570.  
  571. Return the current video mode value, 7 indicates text mode, 99 
  572. indicates graphics.
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580. C News 1-08                Page 12                   11 Jun 1988 
  581. ================================================================
  582. Programming for the Hercules Graphics Card by David Cheslow.
  583. ================================================================
  584.  
  585. ASM SPEEDUP:
  586.  
  587. If your compiler has a function to initialize FAR memory to a 
  588. CHARACTER ascii value then you have an easy speedup to replace the 
  589. loop which clears Hercules memory.  This function might be called 
  590. something like 'farmemset' or 'farmemfill'.  If you are using a
  591. large memory model then look for 'memset' or 'memfill'.  Double
  592. check that the function addresses FAR memory or you'll get a system
  593. crash for sure!  All we are really trying to accomplish here is to
  594. fill 65536 bytes of far memory, starting at 'h_p', with the character
  595. ascii 0. This speedup (and several similar ones) will be used in many
  596. of the functions presented in future articles so your time will be
  597. well spent getting it right.  This speedup will make the routine
  598. almost instantaneous!  If your compiler doesn't have such a function
  599. then try this ASM routine:
  600.  
  601.       PUSH   BP
  602.       MOV    BP,SP
  603.       MOV    DI,[BP+6]
  604.       MOV    ES,[BP+8]
  605.       MOV    AX,[BP+10]
  606.       MOV    CX,[BP+12]
  607.       JCXZ   QUIT:
  608.       CLD
  609.       REP STOSB
  610. QUIT: RETFAR
  611.  
  612. Where [BP+6] is the offset portion of a far pointer, [BP+8] is the 
  613. segment portion of a far pointer, [BP+10] is the character to fill 
  614. with and [BP+12] is the number of bytes to fill.
  615.  
  616. Before using this ASM code, be sure to check whether or not your
  617. compilers requires you to preserve the ES segment register.
  618.  
  619. 3) Switching between the two Hercules graphics 'pages'
  620.  
  621. After that last one this should be a breeze.  The Hercules maintains 
  622. 2 separate graphics pages and allows an almost instantaneous switch
  623. between them.  Much of the information about the techniques used in 
  624. this function have already been covered, so the description will be
  625. brief.  Unfortunately, I know of no way to make the mouse cursor
  626. appear on the second graphics page.  Anybody got any ideas?
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634. C News 1-08                Page 13                   11 Jun 1988 
  635. ================================================================
  636. Programming for the Hercules Graphics Card by David Cheslow.
  637. ================================================================
  638.  
  639. Here's the function:
  640.  
  641. int h_setvpage(page)
  642. int page;
  643. {
  644.    extern int h_vpage;
  645.    int old_page;
  646.    if(h_vmode==99)
  647.    {
  648.       outp(MODEPORT,10+((page==1)?128:0));
  649.    }
  650.    old_page=h_vpage;
  651.    h_vpage=page;
  652.    return(old_page);
  653. }
  654.  
  655.  
  656. PARAMETER:
  657.  
  658. The only parameter passed to this function is the page which is
  659. to be made the visible page.  If the value is 1 then the second
  660. page is made visible.  Any other value causes the first page (#0)
  661. to become visible.
  662.  
  663. LOCAL VARIABLE:
  664.  
  665. 'old_page' is used to store the number of the page which is visible
  666. when the function is called.  This is also the value returned by the
  667. function.
  668.  
  669. PROCEDURE:
  670.  
  671. The 8th bit of MODEPORT determines which page is currently visible.  
  672. Since the pages are only meaningful in graphics mode and because
  673. we wouldn't be changing the visible page unless the adapter is on,
  674. we know that the 2nd and 4th bits are 1.  To select page 1, we add
  675. 128; for page 0, we add 0.
  676.  
  677. 'old_page' is set equal to the external variable which contains the
  678. previously visible page.  The new visible page is loaded into h_vpage
  679. and the previously visible page is returned.
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688. C News 1-08                Page 14                   11 Jun 1988 
  689. ================================================================
  690. Programming for the Hercules Graphics Card by David Cheslow.
  691. ================================================================
  692.  
  693. 4)  Turning the Hercules adapter on/off
  694.  
  695. If you followed the h_init and the h_setvpage functions then this
  696. one should be obvious.
  697.  
  698. void h_onoff(on)
  699. int on;
  700. {
  701.    outp(MODEPORT,((on)?8:0)+((h_vpage)?128:0)+((h_vmode==99)?2:0));
  702. }
  703.  
  704. If the parameter 'on' has a value other than 0 the adapter is turned 
  705. on, otherwise it is turned off.
  706.  
  707. 5) Detect the presence of a mouse driver
  708.  
  709. The mouse is controlled by making calls to interrupt 33 hex with
  710. various values in the NON-SEGMENT registers.  The 'int86' function
  711. works well for this.  When register ax is 0 the mouse driver
  712. is initialized and returns the number of buttons on the mouse in
  713. the bx register.  The ax register contains -1 if a mouse is present,
  714. otherwise it contains 0.
  715.  
  716. Here is the function:
  717.  
  718. int m_int(buttons)
  719. int *buttons;
  720. {
  721.    union REGS reg;
  722.    reg.x.ax=0;
  723.    int86(0x33,®,®);
  724.    *buttons=reg.x.bx;
  725.    return(reg.x.ax);
  726. }
  727.  
  728. When calling this function note that a pointer to 'buttons' is
  729. passed as the parameter.  The function call will look like this -
  730. x=m_init(&y).
  731.  
  732. 6) Turning the mouse cursor on/off
  733.  
  734. Call the mouse interrupt with 1 in the ax register turns the mouse
  735. cursor on.  If 2 is in ax then the mouse cursor is turned off.  Note
  736. that the number of calls to mouse on must be the same as the number
  737. of calls to mouse off.  In other words, if the mouse on call is made
  738. twice then the mouse off call must be made twice to turn the cursor
  739. off.
  740.  
  741.  
  742. C News 1-08                Page 15                   11 Jun 1988 
  743. ================================================================
  744. Programming for the Hercules Graphics Card by David Cheslow.
  745. ================================================================
  746.  
  747. Here's the function:
  748.  
  749. void m_cursor(on)
  750. int on;
  751. {
  752.    union REGS reg;
  753.    reg.x.ax=((on)?1:2);
  754.    int86(0x33,®,®);
  755. }
  756.  
  757. If 'on' ==0 then the mouse cursor is turned off, otherwise it is
  758. turned on.
  759.  
  760. THE DEMO:
  761.  
  762. If you are using the demo program with a mouse installed, note
  763. that the mouse can not move over the entire screen.  The fix for
  764. that will be in my next article.  Other than that, the demo should
  765. be self explanatory.  The only functions you need to compile it
  766. are 'printf' 'getch' and 'exit'.
  767.  
  768. C News 1-08                Page 16                   11 Jun 1988 
  769. ================================================================
  770. Latest Versions of Commercial/PD Software.
  771. ================================================================
  772.  
  773. Compilers:          Ver:           
  774. ---------           ----
  775.  
  776. Microsoft C         5.10
  777. QuickC              1.01
  778.  
  779. TurboC              1.5       /* With a rumored 2.0 out */
  780. Datalight           ?
  781. MIX C               ?
  782. PowerC              ?
  783. Lattice C           ?
  784. Watcom              6.0
  785.  
  786. C News 1-08                Page 17                   11 Jun 1988 
  787. ================================================================
  788. ARTICLE SUBMISSION STANDARDS AND ADDRESSES
  789. ================================================================
  790.  
  791.   
  792.      As I have repeatedly stated in this newsletter and previous  
  793. issues, I would like to see user-submitted articles, reviews or  
  794. questions.  Listed below are the standards that should be  
  795. followed to make my job easier as an editor.  
  796.   
  797.   
  798.    - Articles should be submitted in a ASCII non-formatted  
  799.      file.  (Margins 0-65 PLEASE)
  800.   
  801.    - If the article include code fragments as examples. Then  
  802.      you can include the entire source file if you like for   
  803.      inclusion with the newsletter.  
  804.   
  805.    - Book or magazine reviews should follow the same format,  
  806.      that is outlined in this issue.  The publisher, author,  
  807.      title, and ISBN number are a must.    
  808.   
  809.    - Compiler/and or product reviews, should include the  
  810.      version number and manufacture.  If possible, reviews  
  811.      should include a sample program with benchmarks.  
  812.   
  813.       
  814.      If you have any questions you can contact me at the  
  815. address's included on the next page.  
  816.   
  817. C News 1-08                Page 18                   11 Jun 1988 
  818. ================================================================
  819. ADDRESSES
  820. ================================================================
  821.   
  822.      The C BBS is located at:  
  823.   
  824.           C BBS  
  825.           % BCL Limited  
  826.           P.O. Box 9162  
  827.           McLean VA, 22102  
  828.   
  829.   
  830.      or you can send netmail to:  
  831.   
  832.   
  833.      1:109/713   
  834.   
  835.   
  836.   
  837.   
  838. C News 1-08                Page 19                   11 Jun 1988 
  839. ================================================================
  840. USER RESPONSE FORM
  841. ================================================================
  842.   
  843.    This form will be included as a regular feature in all future  
  844. issues of C NEWS.  
  845.   
  846.   
  847.   
  848. What did you think of the content of this Issue?  _____________  
  849.        
  850. _______________________________________________________________  
  851.  
  852. What improvements can you think of that would make C News a  
  853. better tool for the C Community?  
  854.   
  855. _______________________________________________________________  
  856.  
  857. _______________________________________________________________  
  858.   
  859.   
  860. What is your favorite section or sections?  ___________________  
  861.   
  862. _______________________________________________________________  
  863.   
  864.   
  865. What don't you like about C News?  ____________________________  
  866.   
  867. _______________________________________________________________  
  868.   
  869.   
  870. Additional Comments:  _________________________________________  
  871.   
  872. _______________________________________________________________  
  873.   
  874. _______________________________________________________________  
  875.   
  876. _______________________________________________________________  
  877.   
  878. C News 1-08                Page 20                   11 Jun 1988 
  879. ================================================================
  880.                             INDEX             
  881. ================================================================
  882.   
  883.      Subject:                                          Issue:  
  884.   
  885.      Articles:  
  886.   
  887.      Additional Comments of Filename Wild..             6 
  888.      Beginning C Functions                              7 
  889.      C Spot Run: A User Supported Library               7 
  890.      Filename Wildcard Expansion in MSC                 4  
  891.      Integrated Environment: TC & QC                    5  
  892.      Programming the Hercules Graphics Card             8
  893.      Talking with a Fossil                              5  
  894.      TurboC and Interrupts: A few Questions             2  
  895.         
  896.      Book Reviews:  
  897.  
  898.      C Chest: and other treasures.                      6 
  899.      C Database Development                             1  
  900.      C Programming Guide                                1  
  901.      C Programming Language                             1  
  902.      C Programmer's Guide to Serial Communications      3  
  903.      C Programmer's Library                             1  
  904.      C Primer Plus                                      1  
  905.      C the Complete Reference                           2  
  906.      Crafting C Tools for the IBM PC                    2  
  907.      Learning to Program in C                           1  
  908.      Microsoft C Programming on the IBM PC              1  
  909.      MS-DOS Developer's Guide                           4  
  910.      Programming in Windows                             3  
  911.      Reliable Data Structures in C                      1  
  912.      TurboC: Memory Resident Utilities                  5  
  913.      TurboC Programmer's Reference Book                 2  
  914.   
  915.    
  916.      Compilers:   
  917.   
  918.      QuickC                                             1 
  919.        
  920.      Software Reviews:   
  921.     
  922.      Bplus11.arc                                        3  
  923.      C_Dates.arc                                        4  
  924.      Cdate.arc                                          4  
  925.      Casm.arc                                           3  
  926.      C-subr.arc                                         4  
  927.      Docu.arc                                           3  
  928.      Ezwind.arc                                         8
  929.      Jcl-src.arc                                        4  
  930.      Mscpopup.arc                                       3  
  931.      Ndmake41.arc                                       4  
  932. C News 1-08                Page 21                   11 Jun 1988 
  933. ================================================================
  934.                             INDEX
  935. ================================================================
  936.  
  937.   
  938.      Subject:                                          Issue:  
  939.   
  940.      Software Reviews Cont:  
  941.  
  942.      Nuc-subr.arc                                       3 
  943.      Prndoc.arc                                         6  
  944.      Sed.arc                                            6  
  945.      Shift_c.arc                                        4 
  946.      Sysact11.arc                                       4  
  947.      Tp_to_qc.arc                                       3  
  948.      Xenixarc.arc                                       4  
  949.   
  950. C News 1-08                 Page 22                  30 May 1988  
  951.        
  952. ================================================================  
  953.                       DISTRIBUTION POINTS  
  954. ================================================================  
  955.   
  956.   
  957. Board Name               Number         Net/Node       Sysop  
  958.   
  959. United States  
  960.   
  961. C BBS               (703) 440-0240      1:109/713      Barry Lynch  
  962. Burke, VA  
  963.   
  964. Jaz C-Scape         (904) 724-1377      1:112/1027     Tom Evans  
  965. Jacksonville, FL  
  966.  
  967.   
  968. Eastern C Board     (201) 247-6748      1:107/335      Todd Lehr  
  969.   
  970.   
  971.   
  972.       
  973.   
  974. Canada  
  975.   
  976. Another BBS System  (416) 465-7752      1:148/208      Mark Bowman  
  977. Toronto, Canada  
  978.   
  979. Europe  
  980.   
  981. Fido_N1_1               31-8350-37156     2:500/1        Henk Wevers  
  982. The Netherlands  
  983.   
  984. Australia  
  985.   
  986. Alpha-Centuri BBS   011-61-3-874-3559    3:632/348     David Nugent  
  987.   
  988.   
  989.   
  990.   
  991.  
  992.  
  993.  
  994.  
  995.